import request from './request'

export const permissionApi = {
  // 分页查询权限
  pagePermissions(params) {
    return request.get('/system/permission/page', { params })
  },
  
  // 获取权限树
  getPermissionTree(params) {
    return request.get('/system/permission/tree', { params })
  },
  
  // 获取所有启用的权限
  getAllEnabledPermissions() {
    return request.get('/system/permission/enabled')
  },
  
  // 获取权限详情
  getPermissionById(id) {
    return request.get(`/system/permission/${id}`)
  },
  
  // 创建权限
  createPermission(data) {
    return request.post('/system/permission', data)
  },
  
  // 更新权限
  updatePermission(data) {
    return request.put('/system/permission', data)
  },
  
  // 删除权限
  deletePermission(id) {
    return request.delete(`/system/permission/${id}`)
  },
  
  // 批量删除权限
  deleteBatchPermissions(ids) {
    return request.delete('/system/permission/batch', { data: ids })
  },
  
  // 获取角色的权限列表
  getRolePermissions(roleId) {
    return request.get(`/system/permission/role/${roleId}`)
  },
  
  // 获取用户的权限列表
  getUserPermissions(userId) {
    return request.get(`/system/permission/user/${userId}`)
  }
}